home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Toolbox / Visual Basic Toolbox (P.I.E.)(1996).ISO / graphics / bitlin / frmopen.frm < prev    next >
Text File  |  1995-05-23  |  6KB  |  192 lines

  1. VERSION 2.00
  2. Begin Form frmOpen 
  3.    Caption         =   "Open Bitmap File"
  4.    Height          =   2415
  5.    Left            =   5205
  6.    LinkTopic       =   "Form1"
  7.    ScaleHeight     =   134
  8.    ScaleMode       =   3  'âsâNâZâï
  9.    ScaleWidth      =   217
  10.    Top             =   705
  11.    Width           =   3375
  12.    Begin PictureBox PicBitmaps 
  13.       AutoRedraw      =   -1  'True
  14.       BorderStyle     =   0  'é╚é╡
  15.       Height          =   615
  16.       Left            =   360
  17.       ScaleHeight     =   615
  18.       ScaleWidth      =   375
  19.       TabIndex        =   6
  20.       Top             =   120
  21.       Visible         =   0   'False
  22.       Width           =   375
  23.    End
  24.    Begin PictureBox picTemp 
  25.       AutoRedraw      =   -1  'True
  26.       BorderStyle     =   0  'é╚é╡
  27.       Height          =   615
  28.       Index           =   0
  29.       Left            =   120
  30.       ScaleHeight     =   615
  31.       ScaleWidth      =   135
  32.       TabIndex        =   5
  33.       Top             =   120
  34.       Visible         =   0   'False
  35.       Width           =   135
  36.    End
  37.    Begin CommandButton cmdRedraw 
  38.       Caption         =   "&Redraw"
  39.       Default         =   -1  'True
  40.       Height          =   495
  41.       Left            =   120
  42.       TabIndex        =   4
  43.       Top             =   1440
  44.       Width           =   855
  45.    End
  46.    Begin CommandButton cmdCancel 
  47.       Caption         =   "&Cancel"
  48.       Height          =   495
  49.       Left            =   2160
  50.       TabIndex        =   3
  51.       Top             =   1440
  52.       Width           =   855
  53.    End
  54.    Begin CommandButton cmdOK 
  55.       Caption         =   "&OK"
  56.       Height          =   495
  57.       Left            =   1200
  58.       TabIndex        =   2
  59.       Top             =   1440
  60.       Width           =   855
  61.    End
  62.    Begin TextBox txtBitcnt 
  63.       Height          =   285
  64.       Left            =   2280
  65.       TabIndex        =   1
  66.       Text            =   "1"
  67.       Top             =   840
  68.       Width           =   375
  69.    End
  70.    Begin Image ImgBitmaps 
  71.       Height          =   615
  72.       Left            =   120
  73.       Stretch         =   -1  'True
  74.       Top             =   120
  75.       Width           =   2535
  76.    End
  77.    Begin Label Label1 
  78.       Caption         =   "Enter number of bitmap images in this file:"
  79.       FontBold        =   0   'False
  80.       FontItalic      =   0   'False
  81.       FontName        =   "Arial"
  82.       FontSize        =   9.75
  83.       FontStrikethru  =   0   'False
  84.       FontUnderline   =   0   'False
  85.       Height          =   495
  86.       Left            =   120
  87.       TabIndex        =   0
  88.       Top             =   840
  89.       Width           =   2055
  90.    End
  91. End
  92. Sub cmdCancel_Click ()
  93. 'cancel file open operation
  94.  
  95.  frmOpen.Tag = ""     'no file was selected
  96.  frmOpen.Hide         'hide this Open dialog box
  97.  
  98. End Sub
  99.  
  100. Sub cmdOK_Click ()
  101. 'return name of selected file in tag property of the form
  102.  
  103. If txtBitcnt.Text = "" Then         'check if a file was selected
  104.  Beep                                    'if not, beep and display error message
  105.  MsgBox ("Please enter how many bitmap images are contained in this picture.")
  106. Else
  107.  frmOpen.Tag = txtBitcnt.Text        'set file name to form's tag
  108.  procCutBit                          'divide image to each corresponding images
  109.  frmOpen.Hide                        'hide Open dialog
  110. End If
  111.  
  112. End Sub
  113.  
  114. Sub cmdRedraw_Click ()
  115.  
  116.  Form_resize        'readjust Open dialog form size and redraw selected bitmap image
  117.  
  118. End Sub
  119.  
  120. Sub Form_Activate ()
  121.  ImgBitmaps.Picture = LoadPicture(frmGetFile.Tag)     'display content of selected BMP file
  122.  ImgBitmaps.Refresh
  123. End Sub
  124.  
  125. Sub Form_Load ()
  126.  
  127.  ImgBitmaps.Width = Val(frmMain.Tag)      'Set width of object to value entered in Item Height of main form
  128.  ImgBitmaps.Height = Val(frmMain.Tag)     'set height = width of object
  129.  
  130. End Sub
  131.  
  132. Sub Form_resize ()
  133. 'check if all bitmap images are displayed on screen.
  134. 'if not, enlarge form size so they will be displayed
  135.  
  136.  ImgBitmaps.Width = Val(frmMain.Tag) * Val(txtBitcnt.Text)
  137.  
  138. 'check horizontally
  139.  If (ImgBitmaps.Left + ImgBitmaps.Width) * screen.TwipsPerPixelX > frmOpen.Width Then
  140.    frmOpen.Width = (ImgBitmaps.Width) * screen.TwipsPerPixelX + (ImgBitmaps.Left * screen.TwipsPerPixelX) * 3
  141.  End If
  142.  
  143. 'check vertically
  144.  If frmOpen.Height < (ImgBitmaps.Height * screen.TwipsPerPixelY * 5) Then
  145.    frmOpen.Height = ImgBitmaps.Height * screen.TwipsPerPixelY * 5
  146.  End If
  147.  
  148.  ImgBitmaps.Refresh   'redraw image
  149.  
  150. End Sub
  151.  
  152. Sub procCutBit ()
  153. 'separate bitmap image to number of bitmap images to picTemp array objects
  154. 'these separated bitmap images are later copied to the images in status bar
  155.  
  156. picBitmaps.Top = ImgBitmaps.Top          'Move picBitmaps over to ImgBitmaps
  157. picBitmaps.Left = ImgBitmaps.Left
  158. picBitmaps.Width = ImgBitmaps.Width
  159. picBitmaps.Height = ImgBitmaps.Height
  160. picBitmaps.Picture = ImgBitmaps.Picture
  161.  
  162. picTemp(0).Top = ImgBitmaps.Top
  163.  
  164. For cnt = 0 To txtBitcnt - 1             'Separate bitmap images
  165.  If cnt > 0 Then                           'Create new bitmap object
  166.   Load picTemp(cnt)
  167.  End If
  168.  picTemp(cnt).Left = ImgBitmaps.Left + Val(frmMain.Tag) * cnt    'set position of object to go underneath corresponding bitmap image
  169.  picTemp(cnt).Width = Val(frmMain.Tag)      'set width of object
  170.  picTemp(cnt).Height = ImgBitmaps.Height    'set height = width of object
  171.                                             'copy bitmap image to picTemp() array
  172.  rtncode = BitBlt(picTemp(cnt).hDC, 0, 0, picTemp(0).Width, picTemp(0).Height, picBitmaps.hDC, picBitmaps.Width / Val(txtBitcnt.Text) * cnt, 0, SRCCOPY)
  173. Next
  174.  
  175. End Sub
  176.  
  177. Sub txtBitcnt_KeyPress (KeyAscii As Integer)
  178. 'when number of bitmaps in a file is changed, change image width and redisplay it
  179.  
  180. If KeyAscii = 13 Then         'check if Enter key was pressed
  181.  txtBitcnt_LostFocus              'redraw image to new size
  182. End If
  183.  
  184. End Sub
  185.  
  186. Sub txtBitcnt_LostFocus ()
  187.  
  188. Form_resize          'resize the form and redisplay it
  189.  
  190. End Sub
  191.  
  192.